package com.hspedu.interface_;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/1/28
 * @time 10:49
 */
public class Interface2 {
    public static void main(String[] args) {
        Computer computer = new Computer();
        Phone phone = new Phone();
        Camera camera = new Camera();
        computer.work(phone);
        computer.work(camera);
    }
}

interface Usb{
    void start();
    void stop();
}

class Phone implements Usb{

    @Override
    public void start() {
        System.out.println("手机开始工作...");
    }

    @Override
    public void stop() {
        System.out.println("手机停止工作...");
    }
}

class Camera implements Usb{
    @Override
    public void start() {
        System.out.println("相机开始工作...");
    }

    @Override
    public void stop() {
        System.out.println("相机停止工作...");
    }
}

class Computer{
    public void work(Usb usb){
        usb.start();
        usb.stop();
    }
}